package com.itheima.user.controller;

import com.itheima.entity.dto.VisitorDto;
import com.itheima.entity.vo.Result;
import com.itheima.entity.vo.VisitorVo;
import com.itheima.user.service.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author :wujunjie
 * createTime :2022-12-20 20:55
 * description :
 */
@RestController
@RequestMapping("/userService/visitor")
public class VisitorController {

    @Autowired
    private VisitorService visitorService;

    @PostMapping()
    private Result insertVisitor(@RequestBody VisitorDto visitorDto){
        Boolean insert=visitorService.insertVisitor(visitorDto);
        if (insert){
            return Result.success();
        }
        return Result.error();
    }

    @DeleteMapping
    private Result deleteVisitor(@RequestParam(name = "id") String id){
        Boolean delete=visitorService.deleteVisitor(id);
        if (delete){
            return Result.success();
        }
        return Result.error();
    }

    @GetMapping()
    private Result selectVisitor(){
        List<VisitorVo> visitorVo=visitorService.selectVisitor();
        return Result.success(visitorVo);
    }

}
